// Most common use
id mutableArray = [NSMutableArray array];
// May not be what you want
id array = [NSArray array];
id array = [NSMutableArray arrayWithObjects:
@"Plates", @"Plasticware", @"Napkins", nil];
id mutableArray = [NSMutableArray
arrayWithArray:@("A", "B", "C")];
id guestArray = @("Suzy", "Alice", "John", "Peggy", "David");
id sortedArray = [guestArray sortedArrayUsingSelector:@"compare:"];
When removing objects using NSMutableArray's removeObject... methods, note that the objects are sent a release message as they're removed. Thus, the following can cause an error:
id anObj = [aList objectAtIndex:0]; [aList removeObjectAtIndex:0]; [aList addObject:anObj]; // anObj may already be dealloc'd
id guestArray = [NSMutableArray arrayWithContentsOfFile:path];
[guestArray addObject:newGuest];
[guestArray writeToFile:path atomically:YES];
id array = [NSMutableArray arrayWithObjects:
@"Plates", @"Plasticware", @"Napkins", nil];
id description = [array description];
id commaString = @"A, B, C";
id array = [string componentsSeparatedByString:@","];
id dashString = [array componentsJoinedByString:@"- "];
Table of Contents
Next Section